
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <meta name="description" content="">
    <meta name="author" content="hzcmgd">
    <title>树人学习</title>
    <link rel="icon" href="favicon.ico">

    <!-- Bootstrap core CSS -->
    <link href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">

    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <link href="http://v3.bootcss.com/assets/css/ie10-viewport-bug-workaround.css" rel="stylesheet">
    <!-- Custom styles for this template -->
    <link href="/static/pc/reg.css" rel="stylesheet">

    <!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
    <!--[if lt IE 9]><script src="http://v3.bootcss.com/assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
    <script src="http://v3.bootcss.com/assets/js/ie-emulation-modes-warning.js"></script>

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
    <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->

    <script src="http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <script src="/static/admin/js/layer/layer.js"></script>
    <script src="/static/admin/js/laypage/laypage.js"></script>
    <script src="/static/admin/js/laytpl/laytpl.js"></script>
    <link href="/static/admin/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
</head>

<body>
{include file="public/header2" /}

<div class="container container-form"  style="width: 900px; padding: 0 200px;">

    <div class="page-header">
        <h2>个人注册</h2>
    </div>

    <form class="form-horizontal"   name="add" id="add" method="post" action="{:url('user/create')}">

        <div class="form-group">
            <label for="inputEmail3" class="col-sm-2 control-label">角色</label>
            <div class="col-sm-10">
                <select name="role"   class="form-control"  id="role"  onchange="change()">
                    <option value="1">学生</option>
                    <option value="2">家长</option>
                    <option value="3">教师</option>
                    <option value="4">社会人士</option>
                </select>
            </div>
        </div>


        <div class="form-group">
            <label for="username" class="col-sm-2 control-label" id="xjh">学籍号</label>
            <div class="col-sm-10">
                <input class="form-control" type="text" name="username" id="username" value="">
            </div>
        </div>
        <div class="form-group">
            <label for="name" class="col-sm-2 control-label" id="xm">姓名</label>
            <div class="col-sm-10">
                <input class="form-control" type="text" name="name" id="name" value="">
            </div>
        </div>
        <div class="form-group" id="sj">
            <label for="mobile" class="col-sm-2 control-label">预留家长手机</label>
            <div class="col-sm-10">
                <input class="form-control" type="text" name="mobile" id="mobile" value="">
            </div>
            <p class="help-block"></p>
        </div>
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <a href="javascript:;" onclick="reg(); return false;"> <button type="submit" class="btn btn-default btn-cmgd">提交</button></a>
            </div>
        </div>
    </form>


</div><!--/.container-->



<script type="text/javascript">
    function change(){
        var cc = document.getElementById('role').value;
        if(cc==1){
            document.getElementById('sj').style.display='block';
            document.getElementById('xm').innerHTML='学生姓名';
            document.getElementById('xjh').innerHTML='学籍号';
        }
        if(cc==2){
            document.getElementById('sj').style.display='none';
            document.getElementById('xm').innerHTML='学生姓名';
            document.getElementById('xjh').innerHTML='家长手机';
        }

        if(cc==3){
            document.getElementById('sj').style.display='none';
            document.getElementById('xm').innerHTML='教师姓名';
            document.getElementById('xjh').innerHTML='教师手机';
        }
        if(cc==4){

            document.getElementById('sj').style.display='none';
            document.getElementById('xm').innerHTML='姓名';
            document.getElementById('xjh').innerHTML='手机';
        }
    }



    function reg(){

        var role =  document.getElementById('role').value;
        var username =  document.getElementById('username').value;
        var mobile =  document.getElementById('mobile').value;
        var name =  document.getElementById('name').value;

        if( '' == username||name==''){


            layer.msg('请填写完整信息',{icon:5,time:1500,shade: 0.1,});
            return false;
        }

        if(role==1){
            if(''==mobile){

                layer.msg('请填写完整信息',{icon:5,time:1500,shade: 0.1,});
                return false;
            }
        }

        $.post('{:url("user/reg")}',
                {role:role,username:username,mobile:mobile,name:name},
                function(data){
                    console.log(data);
                    if(data.code==1){
                        $('#add').submit();
                    }else{
                        layer.msg(data.msg,{icon:5,time:1500,shade: 0.1,});
                        return false;
                    }
                });
        return false;
    }
</script>



<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
<script src="https://cdn.bootcss.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="http://v3.bootcss.com/assets/js/ie10-viewport-bug-workaround.js"></script>
<script src="http://v3.bootcss.com/examples/offcanvas/offcanvas.js"></script>
</body>
</html>
